package baidu.day06.doudizhu;

import java.util.ArrayList;
import java.util.Collections;

// Created: 08/07/2025, ChangJiang Ru
public class PokerGame {
    // Create a static collection
    static ArrayList<String> list = new ArrayList<>();

    // Create a static code block
    static{

        // Prepare card
        String[] color = {"♣", "♥", "♦", "♣"};
        String[] number = {"3", "4", "5", "6", "7", "8", "9", "10", "J", "Q", "K", "A", "2"};

        for(String c:color)
        {
            for (String n:number)
            {
                list.add(c + n);
            }
        }

        // Add the "Big Joker" and "Little Joker"
        list.add("Big Joker");
        list.add("Little Joker");


    }

    public PokerGame()
    {
        // Arrange sequence
        Collections.shuffle(list);

        // Player get the Poker
        ArrayList<String> lord = new ArrayList<>();
        ArrayList<String> player1 = new ArrayList<>();
        ArrayList<String> player2 = new ArrayList<>();
        ArrayList<String> player3 = new ArrayList<>();

        // Order the sequence
        for (int i = 0; i < list.size(); i++) {
            String poker = list.get(i);
            if (i <= 2)
            {
                lord.add(poker);
                continue;
            }

            if(i % 3 == 0)
            {
                player1.add(poker);
            }
            else if (i % 3 == 1)
            {
                player2.add(poker);
            }
            else if(i % 3 == 2)
            {
                player3.add(poker);
            }
        }

        // Look the every player poker
        lookPoker("Lord", lord);
        lookPoker("Jake", player1);
        lookPoker("Tom", player2);
        lookPoker("Nike", player3);
    }

    public void lookPoker(String name, ArrayList<String> list)
    {
        System.out.println(name + ": ");
        for(String poker:list)
        {
            System.out.print(poker + " ");
        }
        System.out.println();
    }
}
